package com.eshop.modules.mp.handler;

import com.eshop.modules.mp.builder.TextBuilder;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import java.util.Map;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import org.springframework.stereotype.Component;

@Component
public class LocationHandler extends AbstractHandler
{
    public WxMpXmlOutMessage handle(final WxMpXmlMessage wxMessage, final Map<String, Object> context, final WxMpService wxMpService, final WxSessionManager sessionManager) {
        if (wxMessage.getMsgType().equals("location")) {
            try {
                final String content = "感谢反馈，您的的地理位置已收到！";
                return new TextBuilder().build(content, wxMessage, null);
            }
            catch (Exception e) {
                this.logger.error("位置消息接收处理失败", (Throwable)e);
                return null;
            }
        }
        this.logger.info("上报地理位置，纬度 : {}，经度 : {}，精度 : {}", new Object[] { wxMessage.getLatitude(), wxMessage.getLongitude(), String.valueOf(wxMessage.getPrecision()) });
        return null;
    }
}
